﻿package mortal.game.resource.info.item
{
    import Message.Public.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;

    public class ItemData extends Object
    {
        private var _serverData:SPlayerItem;
        private var _extInfo:ItemExInfo;
        private var _itemInfo:ItemInfo;
        private var _isClone:Boolean;
        public var extData:Object;
        public var extDataType:int = -1;
        public var isForceShowBind:Boolean = false;

        public function ItemData(param1, param2:Boolean = false)
        {
            var _loc_3:SPlayerItem = null;
            this._serverData = new SPlayerItem();
            this._isClone = param2;
            if (param1 is SPlayerItem)
            {
                this.data = param1;
            }
            else if (param1 is int)
            {
                _loc_3 = new SPlayerItem();
                _loc_3.itemCode = param1;
                this.data = _loc_3;
            }
            return;
        }// end function

        public function get itemInfo() : ItemInfo
        {
            return this._itemInfo;
        }// end function

        public function get extInfo() : ItemExInfo
        {
            return this._extInfo;
        }// end function

        public function set extInfo(param1:ItemExInfo) : void
        {
            this._extInfo = param1;
            return;
        }// end function

        public function get serverData() : SPlayerItem
        {
            return this._serverData;
        }// end function

        public function set serverData(param1:SPlayerItem) : void
        {
            this._serverData = param1;
            return;
        }// end function

        public function set data(param1:SPlayerItem) : void
        {
            var _loc_2:Object = null;
            this._serverData = param1;
            if (this._isClone)
            {
                this._itemInfo = ItemConfig.instance.getConfig(param1.itemCode).clone();
            }
            else
            {
                this._itemInfo = ItemConfig.instance.getConfig(param1.itemCode);
            }
            if (this._serverData.jsStr != null && this._serverData.jsStr != "")
            {
                _loc_2 = JSON.parse(param1.jsStr);
                if (_loc_2)
                {
                    if (this._extInfo)
                    {
                        this._extInfo.clear();
                    }
                    else
                    {
                        this._extInfo = new ItemExInfo();
                    }
                    this._extInfo.putObject(_loc_2);
                }
                else
                {
                    this._extInfo = null;
                }
            }
            return;
        }// end function

        public function get itemAmount() : int
        {
            if (this._serverData)
            {
                return this._serverData.itemAmount;
            }
            return -1;
        }// end function

        public function get addPercent() : Number
        {
            if (this._extInfo == null)
            {
                return 0;
            }
            var _loc_1:* = EquipAdvanceConfig.instance.getPercentByQual(this.extInfo.qual) / 100;
            return _loc_1;
        }// end function

        public function set itemAmount(param1:int) : void
        {
            this._serverData.itemAmount = param1;
            return;
        }// end function

        public function get name() : String
        {
            return this.itemInfo.name;
        }// end function

        public function get uid() : String
        {
            return this._serverData.uid;
        }// end function

        public function get itemCode() : int
        {
            return this.itemInfo.code;
        }// end function

        public function get bind() : int
        {
            return this.itemInfo.bind;
        }// end function

        public function get posType() : int
        {
            return this._serverData.posType;
        }// end function

    }
}
